home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / pstricks / ps / textpath.pro < prev   
Text File  |  1993-04-07  |  2KB  |  102 lines

  1. %!
  2. % PostScript header file textpath.pro
  3. % For putting text along curve with textpath.tex and PSTricks
  4. % Version: 0.93a
  5. % Date:    93/03/12
  6. % For copying restrictions, see pstricks.doc or pstricks.tex.
  7.  
  8. /tx@TextPathDict 40 dict def
  9. tx@TextPathDict begin
  10.  
  11. /PathPosition
  12. { /targetdist exch def
  13.   /pathdist 0 def
  14.   /continue true def
  15.   /X { newx } def /Y { newy } def /Angle 0 def
  16.   gsave
  17.     flattenpath
  18.     { movetoproc }  { linetoproc } { curvetoproc } { closepathproc }
  19.     pathforall
  20.   grestore
  21. } def
  22.  
  23. /movetoproc { continue { @movetoproc } { pop pop } ifelse } def
  24.  
  25. /@movetoproc
  26. { /newy exch def /newx exch def
  27.   /firstx newx def /firsty newy def
  28. } def
  29.  
  30. /linetoproc { continue { @linetoproc } { pop pop } ifelse } def
  31.  
  32. /@linetoproc
  33. {
  34.   /oldx newx def /oldy newy def
  35.   /newy exch def /newx exch def
  36.   /dx newx oldx sub def
  37.   /dy newy oldy sub def
  38.   /dist dx dup mul dy dup mul add sqrt def
  39.   /pathdist pathdist dist add def
  40.   pathdist targetdist ge
  41.   { pathdist targetdist sub dist div dup
  42.     dy mul neg newy add /Y exch def
  43.     dx mul neg newx add /X exch def
  44.     /Angle dy dx atan def
  45.     /continue false def
  46.   } if
  47. } def
  48.  
  49. /curvetoproc { (ERROR: No curveto's after flattenpath!) print } def
  50.  
  51. /closepathproc { firstx firsty linetoproc } def
  52.  
  53. /TextPathShow
  54. { /String exch def
  55.   /CharCount 0 def
  56.   String length
  57.   { String CharCount 1 getinterval ShowChar
  58.     /CharCount CharCount 1 add def
  59.   } repeat
  60. } def
  61.  
  62. /InitTextPath
  63. { gsave
  64.     currentpoint
  65.     /Y exch def /X exch def
  66.     10000000 PathPosition
  67.     pathdist X Hoffset sub sub mul
  68.     Voffset Hoffset sub add
  69.     neg X add /Hoffset exch def
  70.     /Voffset Y def
  71.   grestore
  72. } def
  73.  
  74. /Transform
  75. { PathPosition
  76.   dup
  77.   Angle cos mul Y add exch
  78.   Angle sin mul neg X add exch
  79.   translate
  80.   Angle rotate
  81. } def
  82.  
  83. /ShowChar
  84. { /Char exch def
  85.   gsave
  86.     Char end stringwidth
  87.     tx@TextPathDict begin
  88.     2 div /Sy exch def 2 div /Sx exch def
  89.     currentpoint
  90.     Voffset sub Sy add exch
  91.     Hoffset sub Sx add
  92.     Transform
  93.     Sx neg Sy neg moveto
  94.     Char end tx@TextPathSavedShow
  95.     tx@TextPathDict begin
  96.   grestore
  97.   Sx 2 mul Sy 2 mul rmoveto
  98. } def
  99.  
  100. end
  101. % End textpath.pro
  102.